import BaseView from "../../../cfw/mvc/BaseView";
import GiftMgr from "../model/GiftMgr";
import ModuleManager, { ModuleID } from "../../../cfw/module/ModuleManager";


const { ccclass, property } = cc._decorator;

@ccclass
export default class GiftView extends BaseView {

	@property({ type: cc.Sprite, displayName: "contents$VSprite" })
	contents$VSprite: cc.Sprite = null;

	@property({ type: cc.Button, displayName: "back$VButton" })
	back$VButton: cc.Button = null;

	@property(cc.Prefab)
	prefab: cc.Prefab = null;

	protected model: GiftMgr;


	onLoad() {
		let list = this.model.getList()
		for (let index = 0; index < list.length; index++) {
			const element = list[index];
			let node = cc.instantiate(this.prefab)
			this.controller.initView(node, 'GiftItemVIew', element)
			this.contents$VSprite.node.addChild(node)
		}
	}




	onDestroy() {
		ModuleManager.getLoader(ModuleID.GIFT).release()
	}

	onback$VButtonClick() {
		this.controller.intoLobby()
	}



}